package net.ncraft.mc.ezframework.core;

import com.comphenix.protocol.ProtocolLibrary;
import lombok.Getter;
import net.ncraft.mc.ezframework.core.handler.command.CommandHandler;
import net.ncraft.mc.ezframework.core.handler.configuration.ConfigurationHandler;
import net.ncraft.mc.ezframework.core.handler.database.DatabaseHandler;
import net.ncraft.mc.ezframework.core.handler.packages.PackageCenter;
import net.ncraft.mc.ezframework.core.handler.packages.PackageHandler;
import org.bukkit.plugin.java.JavaPlugin;

public class SpigotEzFrameworkCore {

    @Getter
    private static JavaPlugin plugin;

    public static void run(JavaPlugin plugin) {
        SpigotEzFrameworkCore.plugin = plugin;
        if (plugin.getServer().getPluginManager().isPluginEnabled("ProtocolLib")) {
            PackageCenter.setProtocolManager(ProtocolLibrary.getProtocolManager());
            PackageHandler.load(plugin);
        }
        ConfigurationHandler.load(plugin);
        CommandHandler.load(plugin);
        DatabaseHandler.load(plugin);
        plugin.getLogger().info(plugin.getName() + " is develop by Spigot-EzFramework-Core.");
    }
}
